Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Gas price in USD #290

Merged
merged 10 commits into from
Nov 5, 2024
Merged

Convert Gas price in USD #290

merged 10 commits into from
Nov 5, 2024

Conversation

0xnogo
Copy link
Contributor

@0xnogo 0xnogo commented Nov 1, 2024

  • Convert gas price in USD
  • Convert Juels to Link

// feeComponents are in WEI (ETH * 1e18)
executionFee := new(big.Int).Div(
new(big.Int).Mul(feeComponents.ExecutionFee, nativeTokenPrice.Int),
new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain this calculation in more detail, e.g. why we divide by 1e18?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the logic. First calculating the USD18/WEI (nativeTokenPrice/feeComponents.ExecutionFee) and then multiplying by the gas (in WEI) which will give a price in USD18

@0xnogo 0xnogo marked this pull request as ready for review November 4, 2024 10:18
@0xnogo 0xnogo requested a review from a team as a code owner November 4, 2024 10:18
Copy link

github-actions bot commented Nov 5, 2024

Metric ng/convert-gas-usd main
Coverage 72.9% 72.9%

@0xnogo 0xnogo merged commit c7fea63 into main Nov 5, 2024
4 checks passed
makramkd added a commit that referenced this pull request Nov 6, 2024
@mateusz-sekara mateusz-sekara deleted the ng/convert-gas-usd branch November 8, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants